﻿<!DOCTYPE html>
<html>
	<head>
		<title>XMATCH Function</title>
		<meta charset="utf-8" />
		<meta name="description" content="" />
		<link type="text/css" rel="stylesheet" href="../../../../../../common/main/resources/help/editor.css" />
		<link type = "text/css" rel = "stylesheet" href = "../../images/sprite.css" />
        <script type="text/javascript" src="../callback.js"></script>
        <script type="text/javascript" src="../search/js/page-search.js"></script>
	</head>
	<body>
		<div class="mainpart">
			<div class="search-field">
				<input id="search" class="searchBar" placeholder="Search" type="text" onkeypress="doSearch(event)">
			</div>
			<h1>XMATCH Function</h1>
			<p>The <b>XMATCH</b> function is one of the <a href="../UsageInstructions/InsertFunction.htm#lookupreference" onclick="onhyperlinkclick(this)">lookup and reference functions</a>. It is used to return the relative position of an item in an array. By default, an exact match is required.</p>
			<h3>Syntax</h3>
			<p><b><em>XMATCH(lookup_value, lookup_array, [match_mode], [search_mode])</em></b></p>
			<p>The <b>XMATCH</b> function has the following arguments:</p>
			<table style="width: 40%">
                <tr>
                    <th style="background-color: #f4f4f4" width="150ch"><b>Argument</b></th>
                    <th style="background-color: #f4f4f4"><b>Description</b></th>
                </tr>
                <tr>
                    <td><b><em>lookup_value</em></b></td>
                    <td>A value to search for.</td>
                </tr>
				<tr>
                    <td><b><em>lookup_array</em></b></td>
                    <td>An array or range to search in.</td>
                </tr>
				<tr>
                    <td><b><em>match_mode</em></b></td>
                    <td>An optional argument. The possible values are listed in the table below.</td>
                </tr>
				<tr>
                    <td><b><em>search_mode</em></b></td>
                    <td>An optional argument. The possible values are listed in the table below.</td>
                </tr>
            </table>
			<p>The <b><em>match_mode</em></b> argument can be one of the following:</p>
			<table style="width: 40%">
                <tr>
                    <th style="background-color: #f4f4f4"><b>Value</b></th>
                    <th style="background-color: #f4f4f4"><b>Description</b></th>
                </tr>
                <tr>
                    <td><b><em>0</em></b></td>
                    <td>Set by default. Returns the exact match; if there is no match, the “N/A” is returned instead.</td>
                </tr>
				<tr>
                    <td><b><em>-1</em></b></td>
                    <td>Returns the exact match; if there is none, the next smaller item is returned.</td>
                </tr>
				<tr>
                    <td><b><em>1</em></b></td>
                    <td>Returns the exact match; if there is none, the next larger item is returned.</td>
                </tr>
				<tr>
                    <td><b><em>2</em></b></td>
                    <td>A wildcard match.</td>
                </tr>
            </table>
			<p>The <b><em>search_mode</em></b> argument can be one of the following:</p>
			<table style="width: 40%">
                <tr>
                    <th style="background-color: #f4f4f4"><b>Value</b></th>
                    <th style="background-color: #f4f4f4"><b>Description</b></th>
                </tr>
                <tr>
                    <td><b><em>1</em></b></td>
                    <td>Set by default. Starts a search at the first item.</td>
                </tr>
				<tr>
                    <td><b><em>-1</em></b></td>
                    <td>Starts a reverse search, i.e. at the last item.</td>
                </tr>
				<tr>
                    <td><b><em>2</em></b></td>
                    <td>Starts a binary search with the <b><em>lookup_array</em></b> sorted in ascending order. If not sorted, invalid results will be returned.</td>
                </tr>
				<tr>
                    <td><b><em>-2</em></b></td>
                    <td>Starts a binary search with the <b><em>lookup_array</em></b> sorted in descending order. If not sorted, invalid results will be returned.</td>
                </tr>
            </table>
            <h3>Notes</h3>
			<p>
				Wildcard characters include the question mark (?) that matches a single character and the asterisk (*) that matches multiple characters. If you want to find a question mark or asterisk, type a tilde (~) before the character.
			</p>
			<p>Please note that this is an array formula. To learn more, please read the <a href="../UsageInstructions/InsertArrayFormulas.htm" onclick="onhyperlinkclick(this)">Insert array formulas</a> article.</p>
			<p><a href="../UsageInstructions/InsertFunction.htm#applyfunction" onclick="onhyperlinkclick(this)">How to apply</a> the <b>XMATCH</b> function.</p>
			
			<h3>Examples</h3>
            <p>The figure below displays the result returned by the <b>XMATCH</b> function.</p>
			<p><img alt="XMATCH Function" src="../images/xmatch.png" /></p>
		</div>
	</body>
</html>